
public class Mediator
{
    public static void main(String[] args) {
        ColleagueA ca = new ColleagueA();
        ColleagueB cb = new ColleagueB();
        Mediator m = new Mediator();
        m.ColleagueA = ca;
        m.ColleagueB = cb;
        ca.Mediator = m;
        cb.Mediator = m;
    
        ca.send("message from colleagueA");
        cb.send("message from colleagueB");    
    }

	public ColleagueA ColleagueA;
	public ColleagueB ColleagueB;

	public void send(String message, Colleague colleague)
	{
		if (colleague == ColleagueA)
		{
			ColleagueB.receive(message);
		}
		else
		{
			ColleagueA.receive(message);
		}
	}
}

abstract class Colleague
{
	public Mediator Mediator;
	public void send(String message)
	{
		this.Mediator.send(message, this);
	}
	public abstract void receive(String message);

}

class ColleagueA extends Colleague
{
    @Override
	public void receive(String message)
	{
		System.out.println(String.format("ColleagueA Get %s", message));
	}
}
class ColleagueB extends Colleague
{
    @Override
	public void receive(String message)
	{
		System.out.println(String.format("ColleagueB Get %s", message));
	}
}